#include <iostream>
#include <cstring>
#include <string>

using namespace std;
const int N = 1030;
int f[N][N];

int main()
{
    string a, b;
    while(cin >> a >> b )
    {
        memset(f, 0, sizeof f);
        for (int i = 1; i <= a.size(); ++i)
        {
            for (int j = 1; j <= b.size(); ++j)
            {
                f[i][j] = max(f[i - 1][j], f[i][j - 1]);
                if (a[i - 1] == b[i - 1])
                {
                    f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
                }
            }
        }
        cout << f[a.size()][b.size()] << endl;
    }
    return 0;
}